home *** CD-ROM | disk | FTP | other *** search
- 100 'Term Deposit ("TERMDEPOSIT")
- 110 CLS
- 120 COLOR 0,15 : PRINT "Term Deposit" : COLOR 15,0
- 130 DEFDBL A-Z
- 140 DEFINT M-N
- 150 'Define rounding function
- 160 DEF FNR (V) = SGN (V) * INT (ABS (V) * 100 + .5) / 100
- 170 MONEYFMT$ = "$$##,###,###.##"
- 180 ' Let user select result
- 190 PRINT
- 200 PRINT "Select desired result:"
- 210 PRINT
- 220 PRINT "1 - Initial deposit"
- 230 PRINT "2 - Required interest rate"
- 240 PRINT "3 - Final balance"
- 250 PRINT "4 - Required term"
- 260 PRINT
- 270 INPUT "Result number: ", RESULT
- 280 IF (RESULT < 1) OR (RESULT > 4) THEN PRINT "Select 1-4 only" : GOTO 200
- 290 PRINT
- 300 ' Let user enter data
- 310 PRINT "Do not enter dollar signs or commas"
- 320 PRINT
- 330 IF RESULT <> 1 THEN INPUT "Initial deposit: ", PV
- 340 IF RESULT <> 2 THEN INPUT "Annual interest rate (in percent): ", AR
- 350 IF RESULT <> 3 THEN INPUT "Savings goal: ", FV
- 360 IF RESULT <> 4 THEN INPUT "Term (in months): ", NMONTHS
- 370 INPUT "Annual inflation rate (in percent): ", INFLATION
- 380 INPUT "Marginal tax rate (in percent): ", TAXRATE
- 390 ' Initialize values
- 400 PR = (1 + AR / 100) ^ (1/12) - 1
- 410 'After tax interest rate
- 420 PR = PR * (1 - TAXRATE / 100)
- 430 'Monthly inflation rate
- 440 INFLATION = (1 + INFLATION / 100) ^ (1/12) - 1
- 450 'Effective interest rate
- 460 REFFECTIVE = (1 + PR) / (1 + INFLATION) - 1
- 470 PRINT
- 480 ON RESULT GOTO 500, 540, 670, 710
- 490 ' Result 1: Initial deposit
- 500 PV = FV * (1 + REFFECTIVE) ^ -NMONTHS
- 510 PRINT "Initial deposit: "; USING MONEYFMT$; PV
- 520 END
- 530 ' Result 2: Required interest rate
- 540 INFV = FV * (1 + INFLATION) ^ NMONTHS
- 550 'Monthly interest rate
- 560 PR = (INFV / PV) ^ (1 / NMONTHS) - 1
- 570 'Annual interest rate
- 580 AR = ( (1 + PR) ^ 12 - 1) * 100
- 590 'Adjust for taxes
- 600 RTAXABLE = PR / (1 - TAXRATE / 100)
- 610 RTAXABLE = ( (1 + RTAXABLE) ^ 12 - 1) * 100
- 620 'Print results
- 630 PRINT "Taxable interest rate: "; FNR(RTAXABLE); "%"
- 640 PRINT "Tax-free interest rate:"; FNR(AR); "%"
- 650 END
- 660 ' Result 3: Final balance
- 670 FV = PV * (1 + REFFECTIVE) ^ NMONTHS
- 680 PRINT "Final balance:"; USING MONEYFMT$; FV
- 690 END
- 700 ' Result 4: Required term
- 710 IF FV <> PV THEN NMONTHS = LOG (FV / PV) / LOG (1 + REFFECTIVE) ELSE NMONTHS = 0
- 720 IF NMONTHS < 0 THEN PRINT "No solution" : END
- 730 IF (NMONTHS - INT (NMONTHS) ) < .001 THEN NMONTHS = INT (NMONTHS) ELSE NMONTHS = INT(NMONTHS) + 1
- 740 PRINT "Required number of months: "; NMONTHS
- 750 END